package c.j.a.c.g$g;

import android.text.TextUtils;
import java.util.Iterator;
import java.util.LinkedList;

/* compiled from: InstalledAppManager */
public class c {
    public static volatile c b;
    public static final String[] c = new String[]{"com", "android", "ss"};
    public static final int[] d = new int[]{3101, 3102, 3103, 3201, 3202, 3203};
    public final LinkedList<b> a = new LinkedList();

    /* compiled from: InstalledAppManager */
    public static class b {
        public final String a;
        public final int b;
        public final String c;
        public final String d;
        public final long e;

        public b(String str, int i, String str2, String str3, long j, a aVar) {
            this.a = str;
            this.b = i;
            str = null;
            this.c = str2 != null ? str2.toLowerCase() : null;
            if (str3 != null) {
                str = str3.toLowerCase();
            }
            this.d = str;
            this.e = j;
        }
    }

    public static c b() {
        if (b == null) {
            synchronized (c.class) {
                if (b == null) {
                    b = new c();
                }
            }
        }
        return b;
    }

    /* JADX WARNING: Removed duplicated region for block: B:43:0x005a A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x003e A:{Catch:{ all -> 0x005e }} */
    public static boolean d(java.lang.String r12, java.lang.String r13) {
        /*
        r0 = "\\.";
        r1 = 0;
        r12 = r12.split(r0);	 Catch:{ all -> 0x005e }
        r13 = r13.split(r0);	 Catch:{ all -> 0x005e }
        r0 = r12.length;	 Catch:{ all -> 0x005e }
        if (r0 == 0) goto L_0x005d;
    L_0x000e:
        r0 = r13.length;	 Catch:{ all -> 0x005e }
        if (r0 != 0) goto L_0x0012;
    L_0x0011:
        goto L_0x005d;
    L_0x0012:
        r0 = r12.length;	 Catch:{ all -> 0x005e }
        r2 = 0;
        r3 = 0;
        r4 = 0;
    L_0x0016:
        if (r2 >= r0) goto L_0x0062;
    L_0x0018:
        r5 = r12[r2];	 Catch:{ all -> 0x005e }
        r6 = c;	 Catch:{ all -> 0x005e }
        r7 = r6.length;	 Catch:{ all -> 0x005e }
        r8 = 0;
    L_0x001e:
        r9 = 1;
        if (r8 >= r7) goto L_0x003b;
    L_0x0021:
        r10 = r6[r8];	 Catch:{ all -> 0x005e }
        r11 = r10.equals(r5);	 Catch:{ all -> 0x005e }
        if (r11 == 0) goto L_0x0038;
    L_0x0029:
        r6 = r13.length;	 Catch:{ all -> 0x005e }
        if (r3 >= r6) goto L_0x0036;
    L_0x002c:
        r6 = r13[r3];	 Catch:{ all -> 0x005e }
        r6 = r10.equals(r6);	 Catch:{ all -> 0x005e }
        if (r6 == 0) goto L_0x0036;
    L_0x0034:
        r3 = r3 + 1;
    L_0x0036:
        r6 = 1;
        goto L_0x003c;
    L_0x0038:
        r8 = r8 + 1;
        goto L_0x001e;
    L_0x003b:
        r6 = 0;
    L_0x003c:
        if (r6 != 0) goto L_0x005a;
    L_0x003e:
        r6 = r4;
        r4 = r3;
    L_0x0040:
        r7 = r13.length;	 Catch:{ all -> 0x005e }
        if (r3 >= r7) goto L_0x0058;
    L_0x0043:
        r7 = r13[r3];	 Catch:{ all -> 0x005e }
        r7 = r5.equals(r7);	 Catch:{ all -> 0x005e }
        if (r7 == 0) goto L_0x0055;
    L_0x004b:
        if (r3 != r4) goto L_0x004f;
    L_0x004d:
        r4 = r4 + 1;
    L_0x004f:
        r6 = r6 + 1;
        r7 = 2;
        if (r6 < r7) goto L_0x0055;
    L_0x0054:
        return r9;
    L_0x0055:
        r3 = r3 + 1;
        goto L_0x0040;
    L_0x0058:
        r3 = r4;
        r4 = r6;
    L_0x005a:
        r2 = r2 + 1;
        goto L_0x0016;
    L_0x005d:
        return r1;
    L_0x005e:
        r12 = move-exception;
        r12.printStackTrace();
    L_0x0062:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.c.g$g.c.d(java.lang.String, java.lang.String):boolean");
    }

    public b a(c.j.a.b.a.c.a aVar) {
        f();
        synchronized (this.a) {
            Iterator it = this.a.iterator();
            while (it.hasNext()) {
                b bVar = (b) it.next();
                if (bVar.e > aVar.v) {
                    return bVar;
                }
            }
            return null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:11:0x003a  */
    public void c(java.lang.String r12) {
        /*
        r11 = this;
        r11.f();
        r0 = android.text.TextUtils.isEmpty(r12);
        if (r0 == 0) goto L_0x000a;
    L_0x0009:
        return;
    L_0x000a:
        r0 = c.j.a.c.g.y.a();	 Catch:{ all -> 0x0033 }
        r0 = r0.getPackageManager();	 Catch:{ all -> 0x0033 }
        r1 = 0;
        r1 = r0.getPackageInfo(r12, r1);	 Catch:{ all -> 0x0033 }
        if (r1 == 0) goto L_0x0037;
    L_0x0019:
        r10 = new c.j.a.c.g$g.c$b;	 Catch:{ all -> 0x0033 }
        r4 = r1.versionCode;	 Catch:{ all -> 0x0033 }
        r5 = r1.versionName;	 Catch:{ all -> 0x0033 }
        r1 = r1.applicationInfo;	 Catch:{ all -> 0x0033 }
        r0 = r0.getApplicationLabel(r1);	 Catch:{ all -> 0x0033 }
        r6 = r0;
        r6 = (java.lang.String) r6;	 Catch:{ all -> 0x0033 }
        r7 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x0033 }
        r9 = 0;
        r2 = r10;
        r3 = r12;
        r2.m2266init(r3, r4, r5, r6, r7, r9);	 Catch:{ all -> 0x0033 }
        goto L_0x0038;
    L_0x0033:
        r12 = move-exception;
        r12.printStackTrace();
    L_0x0037:
        r10 = 0;
    L_0x0038:
        if (r10 == 0) goto L_0x0047;
    L_0x003a:
        r12 = r11.a;
        monitor-enter(r12);
        r0 = r11.a;	 Catch:{ all -> 0x0044 }
        r0.add(r10);	 Catch:{ all -> 0x0044 }
        monitor-exit(r12);	 Catch:{ all -> 0x0044 }
        goto L_0x0047;
    L_0x0044:
        r0 = move-exception;
        monitor-exit(r12);	 Catch:{ all -> 0x0044 }
        throw r0;
    L_0x0047:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.c.g$g.c.c(java.lang.String):void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:41:0x00a1 A:{Catch:{ all -> 0x014e }} */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x00df A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x00c5 A:{Catch:{ all -> 0x014e }} */
    public android.util.Pair<c.j.a.c.g$g.c.b, java.lang.Integer> e(c.j.a.b.a.c.a r19) {
        /*
        r18 = this;
        r1 = r18;
        r0 = r19;
        r2 = d;
        r3 = 0;
        r18.f();	 Catch:{ all -> 0x014e }
        r4 = r1.a;	 Catch:{ all -> 0x014e }
        r4 = r4.isEmpty();	 Catch:{ all -> 0x014e }
        if (r4 == 0) goto L_0x0013;
    L_0x0012:
        return r3;
    L_0x0013:
        r4 = r0.m;	 Catch:{ all -> 0x014e }
        r5 = r0.e;	 Catch:{ all -> 0x014e }
        r6 = r0.l;	 Catch:{ all -> 0x014e }
        r7 = r0.k;	 Catch:{ all -> 0x014e }
        r8 = r2.length;	 Catch:{ all -> 0x014e }
        r9 = new c.j.a.c.g$g.c.b[r8];	 Catch:{ all -> 0x014e }
        r10 = r1.a;	 Catch:{ all -> 0x014e }
        monitor-enter(r10);	 Catch:{ all -> 0x014e }
        r11 = r1.a;	 Catch:{ all -> 0x014b }
        r11 = r11.iterator();	 Catch:{ all -> 0x014b }
        r12 = r3;
    L_0x0028:
        r13 = r11.hasNext();	 Catch:{ all -> 0x014b }
        if (r13 == 0) goto L_0x0131;
    L_0x002e:
        r13 = r11.next();	 Catch:{ all -> 0x014b }
        r13 = (c.j.a.c.g$g.c.b) r13;	 Catch:{ all -> 0x014b }
        r14 = r13.e;	 Catch:{ all -> 0x014b }
        r16 = r4;
        r3 = r0.v;	 Catch:{ all -> 0x014b }
        r17 = (r14 > r3 ? 1 : (r14 == r3 ? 0 : -1));
        if (r17 >= 0) goto L_0x0042;
    L_0x003e:
        r4 = r16;
        goto L_0x012e;
    L_0x0042:
        r3 = android.text.TextUtils.isEmpty(r16);	 Catch:{ all -> 0x014b }
        if (r3 == 0) goto L_0x0063;
    L_0x0048:
        if (r12 != 0) goto L_0x004f;
    L_0x004a:
        r3 = c.j.a.c.q.d.c(r19);	 Catch:{ all -> 0x014b }
        r12 = r3;
    L_0x004f:
        if (r12 == 0) goto L_0x0063;
    L_0x0051:
        r3 = c.j.a.c.g.y.a();	 Catch:{ all -> 0x0063 }
        r3 = r3.getPackageManager();	 Catch:{ all -> 0x0063 }
        r4 = r12.applicationInfo;	 Catch:{ all -> 0x0063 }
        r3 = r3.getApplicationLabel(r4);	 Catch:{ all -> 0x0063 }
        r3 = (java.lang.String) r3;	 Catch:{ all -> 0x0063 }
        r4 = r3;
        goto L_0x0065;
    L_0x0063:
        r4 = r16;
    L_0x0065:
        r3 = android.text.TextUtils.isEmpty(r4);	 Catch:{ all -> 0x014b }
        if (r3 != 0) goto L_0x009a;
    L_0x006b:
        r3 = r13.d;	 Catch:{ all -> 0x014b }
        r3 = android.text.TextUtils.isEmpty(r3);	 Catch:{ all -> 0x014b }
        if (r3 != 0) goto L_0x009a;
    L_0x0073:
        r4 = r4.toLowerCase();	 Catch:{ all -> 0x014b }
        r3 = r13.d;	 Catch:{ all -> 0x014b }
        r3 = r4.equals(r3);	 Catch:{ all -> 0x014b }
        if (r3 == 0) goto L_0x0084;
    L_0x007f:
        r3 = 0;
        r9[r3] = r13;	 Catch:{ all -> 0x014b }
        goto L_0x0132;
    L_0x0084:
        r3 = 0;
        r14 = r13.d;	 Catch:{ all -> 0x014b }
        r14 = r4.contains(r14);	 Catch:{ all -> 0x014b }
        if (r14 != 0) goto L_0x0095;
    L_0x008d:
        r14 = r13.d;	 Catch:{ all -> 0x014b }
        r14 = r14.contains(r4);	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x009b;
    L_0x0095:
        r0 = 1;
        r9[r0] = r13;	 Catch:{ all -> 0x014b }
        goto L_0x0132;
    L_0x009a:
        r3 = 0;
    L_0x009b:
        r14 = android.text.TextUtils.isEmpty(r5);	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x00ab;
    L_0x00a1:
        if (r12 != 0) goto L_0x00a7;
    L_0x00a3:
        r12 = c.j.a.c.q.d.c(r19);	 Catch:{ all -> 0x014b }
    L_0x00a7:
        if (r12 == 0) goto L_0x00ab;
    L_0x00a9:
        r5 = r12.packageName;	 Catch:{ all -> 0x014b }
    L_0x00ab:
        r14 = android.text.TextUtils.isEmpty(r5);	 Catch:{ all -> 0x014b }
        if (r14 != 0) goto L_0x00e3;
    L_0x00b1:
        r14 = r13.a;	 Catch:{ all -> 0x014b }
        r14 = android.text.TextUtils.isEmpty(r14);	 Catch:{ all -> 0x014b }
        if (r14 != 0) goto L_0x00e3;
    L_0x00b9:
        r5 = r5.toLowerCase();	 Catch:{ all -> 0x014b }
        r14 = r13.a;	 Catch:{ all -> 0x014b }
        r14 = r5.contains(r14);	 Catch:{ all -> 0x014b }
        if (r14 != 0) goto L_0x00df;
    L_0x00c5:
        r14 = r13.a;	 Catch:{ all -> 0x014b }
        r14 = r14.contains(r5);	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x00ce;
    L_0x00cd:
        goto L_0x00df;
    L_0x00ce:
        r3 = 3;
        r14 = r9[r3];	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x00d4;
    L_0x00d3:
        goto L_0x012e;
    L_0x00d4:
        r14 = r13.a;	 Catch:{ all -> 0x014b }
        r14 = d(r5, r14);	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x00e3;
    L_0x00dc:
        r9[r3] = r13;	 Catch:{ all -> 0x014b }
        goto L_0x012e;
    L_0x00df:
        r0 = 2;
        r9[r0] = r13;	 Catch:{ all -> 0x014b }
        goto L_0x0132;
    L_0x00e3:
        r3 = 4;
        r14 = r9[r3];	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x00e9;
    L_0x00e8:
        goto L_0x012e;
    L_0x00e9:
        r14 = android.text.TextUtils.isEmpty(r6);	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x00f9;
    L_0x00ef:
        if (r12 != 0) goto L_0x00f5;
    L_0x00f1:
        r12 = c.j.a.c.q.d.c(r19);	 Catch:{ all -> 0x014b }
    L_0x00f5:
        if (r12 == 0) goto L_0x00f9;
    L_0x00f7:
        r6 = r12.versionName;	 Catch:{ all -> 0x014b }
    L_0x00f9:
        r14 = android.text.TextUtils.isEmpty(r6);	 Catch:{ all -> 0x014b }
        if (r14 != 0) goto L_0x0116;
    L_0x00ff:
        r14 = r13.c;	 Catch:{ all -> 0x014b }
        r14 = android.text.TextUtils.isEmpty(r14);	 Catch:{ all -> 0x014b }
        if (r14 != 0) goto L_0x0116;
    L_0x0107:
        r6 = r6.toLowerCase();	 Catch:{ all -> 0x014b }
        r14 = r13.c;	 Catch:{ all -> 0x014b }
        r14 = r6.equals(r14);	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x0116;
    L_0x0113:
        r9[r3] = r13;	 Catch:{ all -> 0x014b }
        goto L_0x012e;
    L_0x0116:
        r3 = 5;
        r14 = r9[r3];	 Catch:{ all -> 0x014b }
        if (r14 == 0) goto L_0x011c;
    L_0x011b:
        goto L_0x012e;
    L_0x011c:
        if (r7 > 0) goto L_0x0128;
    L_0x011e:
        if (r12 != 0) goto L_0x0124;
    L_0x0120:
        r12 = c.j.a.c.q.d.c(r19);	 Catch:{ all -> 0x014b }
    L_0x0124:
        if (r12 == 0) goto L_0x0128;
    L_0x0126:
        r7 = r12.versionCode;	 Catch:{ all -> 0x014b }
    L_0x0128:
        r14 = r13.b;	 Catch:{ all -> 0x014b }
        if (r7 != r14) goto L_0x012e;
    L_0x012c:
        r9[r3] = r13;	 Catch:{ all -> 0x014b }
    L_0x012e:
        r3 = 0;
        goto L_0x0028;
    L_0x0131:
        r3 = 0;
    L_0x0132:
        monitor-exit(r10);	 Catch:{ all -> 0x014b }
        r14 = 0;
    L_0x0134:
        if (r14 >= r8) goto L_0x0152;
    L_0x0136:
        r0 = r9[r14];	 Catch:{ all -> 0x014e }
        if (r0 == 0) goto L_0x0148;
    L_0x013a:
        r0 = new android.util.Pair;	 Catch:{ all -> 0x014e }
        r3 = r9[r14];	 Catch:{ all -> 0x014e }
        r2 = r2[r14];	 Catch:{ all -> 0x014e }
        r2 = java.lang.Integer.valueOf(r2);	 Catch:{ all -> 0x014e }
        r0.<init>(r3, r2);	 Catch:{ all -> 0x014e }
        return r0;
    L_0x0148:
        r14 = r14 + 1;
        goto L_0x0134;
    L_0x014b:
        r0 = move-exception;
        monitor-exit(r10);	 Catch:{ all -> 0x014b }
        throw r0;	 Catch:{ all -> 0x014e }
    L_0x014e:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x0152:
        r2 = 0;
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.c.g$g.c.e(c.j.a.b.a.c.a):android.util.Pair");
    }

    public final void f() {
        long currentTimeMillis = System.currentTimeMillis();
        synchronized (this.a) {
            Iterator it = this.a.iterator();
            while (it.hasNext() && currentTimeMillis - ((b) it.next()).e > 1800000) {
                it.remove();
            }
        }
    }

    public void g(String str) {
        f();
        if (!TextUtils.isEmpty(str)) {
            synchronized (this.a) {
                Iterator it = this.a.iterator();
                while (it.hasNext()) {
                    if (str.equals(((b) it.next()).a)) {
                        it.remove();
                        return;
                    }
                }
            }
        }
    }
}
